<?php 
class LoginController extends  Yaf_Controller_Abstract {
    protected function _getSession() {
        return Yaf_Session::getInstance();
    }
	public function loginAction() {

        var_dump(Yaf_Registry::get('db'))
        if ($this->getRequest()->isPost()) {

            $username = $this->getRequest()->getPost('username');
            $password = $this->getRequest()->getPost('password');
            $userinfo = new IndexModel();
            $allinfo  = $userinfo->getIndex($username,md5($password));

            header('Content-type:application/json;charset:utf8');
            if (empty($allinfo)) {
                
                exit(json_encode(array("status" => false, "info" => "登陆失败, 用户不存在！")));

            }
            $this->_getSession()->set('username',$username);
            $this->_getSession()->set('user_info', $allinfo);

            echo json_encode(array("status" => true, "info" => "登陆成功！"));
            exit;

        }

        return true;

        
        //$this->assign("login",'');
		//$this->getView()->assign("login",'');
    }
}
?>